import { Provide, Get, Inject ,Query} from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { WeiboActivityEntity } from '../../entity/activity';
import { WeiboActivityService } from '../../service/activity';
import { WeiboBlogService } from '../../service/weibo';

/**
 * 商品
 */
@Provide()
@CoolController({
  // 添加通用CRUD接口
  api: ['list', 'page'],
  // 设置表实体
  entity: WeiboActivityEntity,
  service: WeiboActivityService,
})
export class AppWeiboActivityController extends BaseController {

  @Inject()
  weiboActivitySrv:WeiboActivityService

  @Inject()
  weiboBlogService:WeiboBlogService


  @Get('/info')
  async info(@Query() id:number) {
   const data = await this.weiboActivitySrv.info(id)
   const count= await this.weiboBlogService.findBlogtoActivityCount(id)
    return this.ok({...data,count});
  }
}
